#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2021-05-24 9:16 上午
# @Author  : yangdy
# @File    : 2021-05-24.893.特殊等价字符串组
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def numSpecialEquivGroups(self, words: List[str]) -> int:
        data = set()

        def s2s(w: str) -> str:
            a1, a2 = w[::2], w[1::2]
            u1, u2 = list(a1), list(a2)
            u1.sort()
            u2.sort()
            return ''.join(u1) + ''.join(u2)
        for word in words:
            wi = s2s(word)
            data.add(wi)
        return len(data)


questions = [
    ["abcd", "cdab", "cbad", "xyzz", "zzxy", "zzyx"],
    ["abc", "acb", "bac", "bca", "cab", "cba"]
]

work(questions, lambda q: Solution().numSpecialEquivGroups(q))

